package com.github.catvod.spider.merge;

import java.util.Iterator;
import java.util.regex.Pattern;

/* loaded from: classes.dex */
public abstract class ms {

    public static final class A extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            for (fa faVar : lm2.Qy()) {
                if (!(faVar instanceof mF) && !(faVar instanceof w2)) {
                    return false;
                }
            }
            return true;
        }

        public String toString() {
            return ":empty";
        }
    }

    public static final class BU extends MC {
        public BU(int i) {
            super(i);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.N() == this.h;
        }

        public String toString() {
            return String.format(":eq(%d)", Integer.valueOf(this.h));
        }
    }

    public static final class E extends MC {
        public E(int i) {
            super(i);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.N() > this.h;
        }

        public String toString() {
            return String.format(":gt(%d)", Integer.valueOf(this.h));
        }
    }

    public static final class EE extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Lm C4 = lm2.C4();
            return (C4 == null || (C4 instanceof HZ) || lm2.N() != C4.s().size() - 1) ? false : true;
        }

        public String toString() {
            return ":last-child";
        }
    }

    public static final class H extends ms {
        private final String h;

        public H(String str) {
            this.h = AR.h(str);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return AR.h(lm2.g6()).contains(this.h);
        }

        public String toString() {
            return String.format(":containsData(%s)", this.h);
        }
    }

    public static abstract class HA extends ms {
        String V0;
        String h;

        public HA(String str, String str2) {
            this(str, str2, true);
        }

        public HA(String str, String str2, boolean z) {
            R2.BQ(str);
            R2.BQ(str2);
            this.h = AR.V0(str);
            boolean z2 = (str2.startsWith("'") && str2.endsWith("'")) || (str2.startsWith("\"") && str2.endsWith("\""));
            str2 = z2 ? str2.substring(1, str2.length() - 1) : str2;
            this.V0 = z ? AR.V0(str2) : AR.j(str2, z2);
        }
    }

    public static final class JL extends ms {
        private final String h;

        public JL(String str) {
            this.h = str;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.w().endsWith(this.h);
        }

        public String toString() {
            return String.format("%s", this.h);
        }
    }

    public static abstract class MC extends ms {
        int h;

        public MC(int i) {
            this.h = i;
        }
    }

    public static final class RN extends ms {
        private final String h;

        public RN(String str) {
            this.h = str;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return this.h.equals(lm2.a());
        }

        public String toString() {
            return String.format("#%s", this.h);
        }
    }

    public static final class Sf extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Lm C4 = lm2.C4();
            return (C4 == null || (C4 instanceof HZ) || !lm2.K().isEmpty()) ? false : true;
        }

        public String toString() {
            return ":only-child";
        }
    }

    public static final class TL extends MC {
        public TL(int i) {
            super(i);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm != lm2 && lm2.N() < this.h;
        }

        public String toString() {
            return String.format(":lt(%d)", Integer.valueOf(this.h));
        }
    }

    public static final class Tw extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return true;
        }

        public String toString() {
            return "*";
        }
    }

    public static final class V extends pt {
        public V(int i, int i2) {
            super(i, i2);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected int V0(Lm lm, Lm lm2) {
            return lm2.N() + 1;
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected String j() {
            return "nth-child";
        }
    }

    public static final class W extends HA {
        public W(String str, String str2) {
            super(str, str2);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h) && AR.h(lm2.j(this.h)).contains(this.V0);
        }

        public String toString() {
            return String.format("[%s*=%s]", this.h, this.V0);
        }
    }

    public static final class aF extends ms {
        private final String h;

        public aF(String str) {
            this.h = str;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.w().equals(this.h);
        }

        public String toString() {
            return String.format("%s", this.h);
        }
    }

    public static final class c extends HA {
        public c(String str, String str2) {
            super(str, str2);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h) && this.V0.equalsIgnoreCase(lm2.j(this.h).trim());
        }

        public String toString() {
            return String.format("[%s=%s]", this.h, this.V0);
        }
    }

    public static final class cy extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Lm C4 = lm2.C4();
            return (C4 == null || (C4 instanceof HZ) || lm2.N() != 0) ? false : true;
        }

        public String toString() {
            return ":first-child";
        }
    }

    public static final class d extends ms {
        private final String h;

        public d(String str) {
            R2.BQ(str);
            this.h = AR.h(str);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Iterator<tF> it = lm2.I().oC().iterator();
            while (it.hasNext()) {
                if (AR.h(it.next().getKey()).startsWith(this.h)) {
                    return true;
                }
            }
            return false;
        }

        public String toString() {
            return String.format("[^%s]", this.h);
        }
    }

    public static final class i extends HA {
        public i(String str, String str2) {
            super(str, str2, false);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h) && AR.h(lm2.j(this.h)).startsWith(this.V0);
        }

        public String toString() {
            return String.format("[%s^=%s]", this.h, this.V0);
        }
    }

    public static final class j extends HA {
        public j(String str, String str2) {
            super(str, str2);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return !this.V0.equalsIgnoreCase(lm2.j(this.h));
        }

        public String toString() {
            return String.format("[%s!=%s]", this.h, this.V0);
        }
    }

    public static final class jH extends pt {
        public jH(int i, int i2) {
            super(i, i2);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected int V0(Lm lm, Lm lm2) {
            if (lm2.C4() == null) {
                return 0;
            }
            return lm2.C4().s().size() - lm2.N();
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected String j() {
            return "nth-last-child";
        }
    }

    public static final class jP extends ms {
        private final Pattern h;

        public jP(Pattern pattern) {
            this.h = pattern;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return this.h.matcher(lm2.Oh()).find();
        }

        public String toString() {
            return String.format(":matchesOwn(%s)", this.h);
        }
    }

    public static final class kb extends ms {
        private final String h;

        public kb(String str) {
            this.h = str;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.hP(this.h);
        }

        public String toString() {
            return String.format(".%s", this.h);
        }
    }

    public static class lW extends pt {
        public lW(int i, int i2) {
            super(i, i2);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected int V0(Lm lm, Lm lm2) {
            int i = 0;
            if (lm2.C4() == null) {
                return 0;
            }
            Iterator<Lm> it = lm2.C4().s().iterator();
            while (it.hasNext()) {
                Lm next = it.next();
                if (next.XA().equals(lm2.XA())) {
                    i++;
                }
                if (next == lm2) {
                    break;
                }
            }
            return i;
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected String j() {
            return "nth-of-type";
        }
    }

    public static final class oe extends ms {
        private final Pattern h;

        public oe(Pattern pattern) {
            this.h = pattern;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return this.h.matcher(lm2.e()).find();
        }

        public String toString() {
            return String.format(":matches(%s)", this.h);
        }
    }

    public static final class p extends ms {
        private final String h;

        public p(String str) {
            this.h = AR.h(str);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return AR.h(lm2.e()).contains(this.h);
        }

        public String toString() {
            return String.format(":contains(%s)", this.h);
        }
    }

    public static final class pK extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Lm C4 = lm2.C4();
            if (C4 == null || (C4 instanceof HZ)) {
                return false;
            }
            Iterator<Lm> it = C4.s().iterator();
            int i = 0;
            while (it.hasNext()) {
                if (it.next().XA().equals(lm2.XA())) {
                    i++;
                }
            }
            return i == 1;
        }

        public String toString() {
            return ":only-of-type";
        }
    }

    public static abstract class pt extends ms {
        protected final int V0;
        protected final int h;

        public pt(int i, int i2) {
            this.h = i;
            this.V0 = i2;
        }

        protected abstract int V0(Lm lm, Lm lm2);

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            Lm C4 = lm2.C4();
            if (C4 == null || (C4 instanceof HZ)) {
                return false;
            }
            int V0 = V0(lm, lm2);
            int i = this.h;
            if (i == 0) {
                return V0 == this.V0;
            }
            int i2 = this.V0;
            return (V0 - i2) * i >= 0 && (V0 - i2) % i == 0;
        }

        protected abstract String j();

        public String toString() {
            return this.h == 0 ? String.format(":%s(%d)", j(), Integer.valueOf(this.V0)) : this.V0 == 0 ? String.format(":%s(%dn)", j(), Integer.valueOf(this.h)) : String.format(":%s(%dn%+d)", j(), Integer.valueOf(this.h), Integer.valueOf(this.V0));
        }
    }

    public static final class q extends ms {
        private final String h;

        public q(String str) {
            this.h = AR.h(str);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return AR.h(lm2.Oh()).contains(this.h);
        }

        public String toString() {
            return String.format(":containsOwn(%s)", this.h);
        }
    }

    public static final class qM extends HA {
        public qM(String str, String str2) {
            super(str, str2, false);
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h) && AR.h(lm2.j(this.h)).endsWith(this.V0);
        }

        public String toString() {
            return String.format("[%s$=%s]", this.h, this.V0);
        }
    }

    public static final class s extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            if (lm instanceof HZ) {
                lm = lm.d1(0);
            }
            return lm2 == lm;
        }

        public String toString() {
            return ":root";
        }
    }

    public static final class sy extends u {
        public sy() {
            super(0, 1);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        public String toString() {
            return ":last-of-type";
        }
    }

    public static class u extends pt {
        public u(int i, int i2) {
            super(i, i2);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected int V0(Lm lm, Lm lm2) {
            int i = 0;
            if (lm2.C4() == null) {
                return 0;
            }
            Dv s = lm2.C4().s();
            for (int N = lm2.N(); N < s.size(); N++) {
                if (s.get(N).XA().equals(lm2.XA())) {
                    i++;
                }
            }
            return i;
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        protected String j() {
            return "nth-last-of-type";
        }
    }

    public static final class uJ extends ms {
        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            if (lm2 instanceof t) {
                return true;
            }
            for (IG ig : lm2.J()) {
                t tVar = new t(iP.n(lm2.MC()), lm2.oC(), lm2.I());
                ig.To(tVar);
                tVar.rl(ig);
            }
            return false;
        }

        public String toString() {
            return ":matchText";
        }
    }

    public static final class x extends ms {
        Pattern V0;
        String h;

        public x(String str, Pattern pattern) {
            this.h = AR.V0(str);
            this.V0 = pattern;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h) && this.V0.matcher(lm2.j(this.h)).find();
        }

        public String toString() {
            return String.format("[%s~=%s]", this.h, this.V0.toString());
        }
    }

    public static final class yh extends ms {
        private final String h;

        public yh(String str) {
            this.h = str;
        }

        @Override // com.github.catvod.spider.merge.ms
        public boolean h(Lm lm, Lm lm2) {
            return lm2.i4(this.h);
        }

        public String toString() {
            return String.format("[%s]", this.h);
        }
    }

    public static final class z extends lW {
        public z() {
            super(0, 1);
        }

        @Override // com.github.catvod.spider.merge.ms.pt
        public String toString() {
            return ":first-of-type";
        }
    }

    protected ms() {
    }

    public abstract boolean h(Lm lm, Lm lm2);
}
